home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Technical Documentation / C.S.M.P. Digests / csmp-digest-v3-035 / doubleCR.1 < prev   
Encoding:
Text File  |  1994-07-07  |  71.6 KB  |  2,084 lines

  1. C.S.M.P. Digest             Wed, 15 Jun 94       Volume 3 : Issue 35
  2.  
  3. Today's Topics:
  4.  
  5.         "Magical" conversion from (char *) to Pascal string in C++
  6.         "New" bugs in 'develop' floating window code?
  7.         Detecting Universal Headers?
  8.         Enumerating messages from PowerTalk
  9.         MicroSeconds trap # and arguments?
  10.         Ok, where's my Quickdraw globals?  (Help!)
  11.         Symantec C++ 7.0- any good?
  12.         Thread Mgr for blocking I-O
  13.  
  14.  
  15.  
  16. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  17. (pottier@clipper.ens.fr).
  18.  
  19. The digest is a collection of article threads from the internet newsgroup
  20. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  21. regularly and want an archive of the discussions.  If you don't know what a
  22. newsgroup is, you probably don't have access to it.  Ask your systems
  23. administrator(s) for details.  If you don't have access to news, you may
  24. still be able to post messages to the group by using a mail server like
  25. anon.penet.fi (mail help@anon.penet.fi for more information).
  26.  
  27. Each issue of the digest contains one or more sets of articles (called
  28. threads), with each set corresponding to a 'discussion' of a particular
  29. subject.  The articles are not edited; all articles included in this digest
  30. are in their original posted form (as received by our news server at
  31. nef.ens.fr).  Article threads are not added to the digest until the last
  32. article added to the thread is at least two weeks old (this is to ensure that
  33. the thread is dead before adding it to the digest).  Article threads that
  34. consist of only one message are generally not included in the digest.
  35.  
  36. The digest is officially distributed by two means, by email and ftp.
  37.  
  38. If you want to receive the digest by mail, send email to listserv@ens.fr
  39. with no subject and one of the following commands as body:
  40.     help                        Sends you a summary of commands
  41.     subscribe csmp-digest Your Name    Adds you to the mailing list
  42.     signoff csmp-digest            Removes you from the list
  43. Once you have subscribed, you will automatically receive each new
  44. issue as it is created.
  45.  
  46. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  47. Questions related to the ftp site should be directed to
  48. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  49. digest are available there.
  50.  
  51. Also, the digests are available to WAIS users.  To search back issues
  52. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  53. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  54.  
  55.  
  56. -------------------------------------------------------
  57.  
  58. >From oleg@ponder.csci.unt.edu (Kiselyov Oleg)
  59. Subject: "Magical" conversion from (char *) to Pascal string in C++
  60. Date: 31 May 1994 14:28:19 GMT
  61. Organization: University of North Texas, Denton
  62.  
  63. There has been some discussion recently about conversion of a C string
  64. to the Pascal string and correctly casting of the result.
  65. I thought I'd throw in my couple of cents:
  66.  
  67. First, let's define the following class
  68.  
  69. class Pstr        // Pascal String, this is just a type conversion
  70. {
  71.   Str255 pas_string;
  72. public:
  73.   Pstr(const char * c_str);
  74.  ~Pstr(void) {}
  75.   operator unsigned char const * () { return pas_string; }
  76. };
  77.  
  78.                 // Used to "implicitly" convert from C to 
  79. Pstr::Pstr(const char * c_str)    // Pascal string 
  80. {
  81.   strncpy((char *)pas_string,c_str,sizeof(*this)-2);
  82.   CtoPstr((char *)pas_string);
  83. }
  84.  
  85. After that, one can write smth like that
  86.  
  87.   char * title = "some title";    
  88.   this_window = NewWindow(nil,rect += window_offset,(Pstr)title,....etc)
  89.  
  90. It is THAT simple: just putting (Pstr) before a C string magically converts
  91. it to a Pascal string and "does" correct casting, while keeping the original
  92. C string intact.
  93.  
  94. The way I figure it, (Pstr)title should make an object of type Pstr
  95. from 'title' by applying the Pstr::Pstr(const char * c_str)
  96. constructor. Since NewWindow() requires a pascal string as its third
  97. argument, the operator 'unsigned char const *' would apply, which
  98. gives exactly what NewWindow() wants. And here how it actually works
  99. (peeked from the object code generated by the Symantec C++ compiler):
  100. the compiler allocates 256 bytes on stack, copies the C string in
  101. there, calls CtoPstr(), and then pushes the address of that temporary
  102. PASCAL string into stack for NewWindow(). After the NewWindow()
  103. returns, the temporary space allocated for the Pascal string is
  104. disposed of (by simply incrementing A7, mind you).  To me, it looks
  105. exactly as I wanted: conversion of a C string into the PASCAL one
  106. without messing up the C string.
  107.  
  108. Here is more of the same idea:
  109.  
  110. class ScreenRect : public Rect
  111. {
  112. public:
  113.   ScreenRect(const Rect& rect)     { *this = *(ScreenRect *)▭ }
  114.   ScreenRect(const rowcol& heightwidth);
  115.   ~ScreenRect(void) {}
  116.   ScreenRect& operator += (const int offset);
  117.   operator Rect * (void) { return this; }
  118.   void print(const char * title = "") const;
  119. };
  120.                 // Create a rectangle of given height/width
  121.                 // positioned at the origin
  122. ScreenRect::ScreenRect(const rowcol& heightwidth)
  123. {
  124.   left = top = 0;
  125.   bottom = heightwidth.row();
  126.   right  = heightwidth.col();
  127. }
  128.  
  129.                 // Shifting a rectangle by the same amount
  130.                 // in X and Y
  131. ScreenRect& ScreenRect::operator += (const int offset)
  132.   top += offset; bottom += offset; left += offset; right += offset;
  133.   return *this;
  134. }
  135.  
  136.  
  137. Then I can write
  138.     ScreenRect sub_horizon(q_bounds());
  139.     sub_horizon.print("sub horizon");
  140.     EraseRect(sub_horizon);
  141.  
  142. or, even crazier,
  143.  
  144. ScreenWindow::ScreenWindow(ScreenRect rect, const char * title)
  145. {
  146.     const int window_offset = 100;        // Cannot be 0 or small!
  147.     this_window = NewWindow(nil,rect += window_offset,(Pstr)title,...
  148. }
  149.  
  150. So, all QuickDraw functions AUTOMATICALLY accept ScreenRect as if it
  151. were Rect *.
  152. This way, one can build C++ classes around all QuickDraw (and other
  153. OS) data types, and one can still use original QuickDraw functions on
  154. the new "objects". I've done just that for a few OS data types, I can
  155. post it if there is some interest.
  156.  
  157. BTW, this all is perfectly legal C++ and would work everywhere. The
  158. code snippets in this post are fragments of an actual working
  159. program. It compiles with Symantec C++ versions 6.0, 6.0.1, and 7.0.
  160.  
  161.                         Oleg
  162.  
  163. P.S. I'm not a frequent reader of this newsgroup, please send any comments
  164. to oleg@ponder.csci.unt.edu or oleg@unt.edu
  165.  
  166.  
  167. +++++++++++++++++++++++++++
  168.  
  169. >From lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
  170. Date: 1 Jun 1994 13:59:08 GMT
  171. Organization: Information & Media Science, Aarhus University, DENMARK
  172.  
  173. In article <2sfhi3$312@hermes.unt.edu>, oleg@ponder.csci.unt.edu (Kiselyov
  174. Oleg) wrote:
  175.  
  176. > There has been some discussion recently about conversion of a C string
  177. > to the Pascal string and correctly casting of the result.
  178. > I thought I'd throw in my couple of cents:
  179. > First, let's define the following class
  180. > class Pstr        // Pascal String, this is just a type conversion
  181. > {
  182. >   Str255 pas_string;
  183. > public:
  184. >   Pstr(const char * c_str);
  185. >  ~Pstr(void) {}
  186. >   operator unsigned char const * () { return pas_string; }
  187. > };
  188. > After that, one can write smth like that
  189. >   char * title = "some title";    
  190. >   this_window = NewWindow(nil,rect += window_offset,(Pstr)title,....etc)
  191. > It is THAT simple: just putting (Pstr) before a C string magically converts
  192. > it to a Pascal string and "does" correct casting, while keeping the original
  193. > C string intact.
  194.  
  195. A friend and I used this approach to implement a string class that worked
  196. transparently with Pascal strings, while providing >255 character strings.
  197. Basically, the character storage had a pascal length byte in front and a C
  198. string terminating zero in the end. When casting to unsigned char*, the
  199. length byte would be set to something <255, and all operations would check
  200. for length byte <255 and drop a terminating zero at the end. This way, the
  201. string object could be passed to pascal routines expecting (VAR
  202. result:StrNNN) parameters, and the resulting pascal string (possibly not
  203. correctly 0 terminated) would be usable.
  204.  
  205. Alas this broke when we switched from Symantec C++ to MetroWerks. We
  206. haven't tried it with the latest release, though.
  207.  
  208. With Symantec C++, it worked great. No more C-String/Str255 hassles. Just
  209. always use String. Period.
  210.  
  211. If there is any interest, I could post the source.
  212.  
  213. > P.S. I'm not a frequent reader of this newsgroup, please send any comments
  214. > to oleg@ponder.csci.unt.edu or oleg@unt.edu
  215.  
  216. --
  217. Lasse Hillerxe Petersen     !     *       \
  218. Information & Media Science !        ---   |
  219. Erhus University            !     /       /
  220. DENMARK                     !
  221.  
  222. ---------------------------
  223.  
  224. >From egurney@vcd.hp.com (Eddy J. Gurney)
  225. Subject: "New" bugs in 'develop' floating window code?
  226. Date: Sat, 28 May 1994 22:10:09 GMT
  227. Organization: Hewlett-Packard VCD
  228.  
  229. I recently incorporated Dean Yu's "WindowExtensions.c" library (article
  230. in 'develop' issue 15, "Floating Windows: Keeping Afloat in the
  231. Window Manager", code off issue 16 or newer do to some bug fixes)
  232. into my application to give it floating window ability. Since then
  233. I've pretty much had to abandon my plans to use floating windows
  234. since Modeless Dialogs do not work correctly with floating windows
  235. [IsDialogEvent()/DialogSelect() no longer work... wish I would have
  236. known that _before_ I started... :-]
  237.  
  238. Anyway, I am interested in using the code in another app and found two
  239. bugs while I was experimenting with it. Since I've seen some discussion
  240. here in c.s.m.p on this code, I thought I'd ask if anyone has already
  241. fixed these before I attempt to do it myself.
  242.  
  243. * First bug:
  244. Open a new window, A. Open a new window, B. Hide window B and dispose of
  245. window A. Now create a new window C. It does NOT get hilited, but it IS
  246. active. I believe this is a bug in ShowReferencedWindow where it does
  247. the following check:
  248.  
  249.     windowBehind = GetNextWindow(windowToShow);
  250.     if (windowBehind == FrontNonFloatingWindow()) {
  251.     if (windowBehind != nil)
  252.     DeactivateWindow(windowBehind);
  253.  
  254.      // Set the highlight state Set
  255.     WindowHilite(windowToShow, true);
  256.     }
  257.  
  258. this will only set windowToShow's hilite state to true if the window
  259. immediately after the one being shown is the frontmost VISIBLE
  260. non-floating window.
  261.  
  262. * Second bug:
  263. Open a new window, A. Open a new window, B. Open a new window, C and
  264. hide window B. Now show window B and hide window C. Now hide window
  265. B, leaving only window A visible. Window A is NOT active and is NOT
  266. hilited.
  267.  
  268. Checking WindowList shows the order C->B->A->0, and that window C is
  269. active and hilited, even though it is not visible. (This same sequence
  270. using ToolBox routines has WindowList order A->B->C->0). I believe this
  271. is a bug in HideReferencedWindow where it says:
  272.  
  273.     if (windowToHide == frontNonFloater) {
  274.     windowBehind = GetNextWindow(windowToHide);
  275.     if (windowBehind != nil) {
  276.         SetNextWindow(windowToHide, GetNextWindow(windowBehind));
  277.         SetNextWindow(windowBehind, windowToHide);
  278.         ...
  279.  
  280. This assumes that 'windowBehind' (the next window in the window list
  281. after the window being hidden) is visible.
  282.  
  283. It would be nice if these routines emulated the behavior of the system
  284. ShowWindow/HideWindow; if anyone has already fixed these bugs or has
  285. ideas on how to fix them so they act like the ToolBox, please let me
  286. know. I'll post the "fixes" if/when I figure them out.
  287.  
  288. -- 
  289. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  290. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  291. "Failures are divided into two classes-- those who thought and never did,
  292.       and those who did and never thought."     John Charles Salak
  293.  
  294. +++++++++++++++++++++++++++
  295.  
  296. >From Thomas Reed <reed@medicine.wustl.edu>
  297. Date: 31 May 1994 14:14:46 GMT
  298. Organization: Washington University
  299.  
  300. In article <CqJ9Kx.3zB@vcd.hp.com> Eddy J. Gurney, egurney@vcd.hp.com
  301. writes:
  302. >I recently incorporated Dean Yu's "WindowExtensions.c" library (article
  303. >in 'develop' issue 15, "Floating Windows: Keeping Afloat in the
  304. >Window Manager", code off issue 16 or newer do to some bug fixes)
  305. >into my application to give it floating window ability.
  306.  
  307. On an aside, does anyone know if you can use this code to create a
  308. floating window that will float over ALL windows at ALL times?  i.e. -
  309. even when other apps are in the front, the window will float over ALL
  310. windows?
  311.  
  312. I know this is possible using some kind of calls from the new IM: Text,
  313. but as I only have the old IMs, I can't use this too easily.  I also
  314. don't want to limit this capability to Sys 7.1 only.  I'd like it to work
  315. in previous versions of Sys 7.
  316.  
  317. Thanks!
  318.  
  319. -Thomas
  320. =====================================================
  321. Thomas Reed                    Washington University
  322. Reed@telesphere.wustl.edu          Medical School
  323. (also:  Reed@medicine.wustl.edu)
  324. - ---------------------------------------------------
  325. Clothes make the man.  Naked people have little or no
  326. influence on society.  -- Mark Twain
  327. =====================================================
  328.  
  329. Opinions posted are not the opinions of Wash. U.
  330.  
  331. +++++++++++++++++++++++++++
  332.  
  333. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  334. Date: Tue, 31 May 1994 19:17:35 GMT
  335. Organization: Apple Computer
  336.  
  337. Thomas Reed, reed@medicine.wustl.edu writes:
  338. > On an aside, does anyone know if you can use this code to create a
  339. > floating window that will float over ALL windows at ALL times?  i.e. -
  340. > even when other apps are in the front, the window will float over ALL
  341. > windows?
  342.  
  343. No. The only ways to do this are:
  344. (A) Build some TSM (Text Services Manager) 'service' windows, which always
  345. float. You need System 7.1 or later for this, since TSM is part of
  346. WorldScript.
  347. (B) Use the Layer Manager, which does exist, but was never made public, was
  348. never extensively tested, and which the Toolbox people swear will finally
  349. disappear next year with the Copland system release. A few 3rd parties did
  350. manager to reverse engineer the API, but they'll definitely have some work to
  351. do when Copland ships.
  352. (C) Punch a hole out of the GrayRgn and patch the Window Manager to draw your
  353. stuff in the hole when it needs updating. Also hook into the Event Manager to
  354. grab mouse clicks in that part of the screen. Note that what you have is not
  355. a window at all, just a hole in the screen, so you are responsible for
  356. drawing the title bar and controls yourself. This is REALLY skanky and REALLY
  357. complicated, but has been done by several shipping extensions.
  358.  
  359. Needless to say I'd recommend (A), even though I hear there are some weird
  360. issues associated with running TSM windows. Donald Brown of CE Software wrote
  361. a little demo app that does this for last years' MacHack; perhaps the source
  362. code is around somewhere.
  363.  
  364. --Jens Alfke
  365.   jens_alfke@powertalk              Rebel girl, rebel girl,
  366.             .apple.com              Rebel girl you are the queen of my world
  367.  
  368. +++++++++++++++++++++++++++
  369.  
  370. >From Joe Francis <Joe.Francis@dartmouth.edu>
  371. Date: 31 May 1994 19:38:09 GMT
  372. Organization: Smooth Roo Software
  373.  
  374. Eddy J. Gurney, egurney@vcd.hp.com writes:
  375. > * First bug:
  376. > Open a new window, A. Open a new window, B. Hide window B and dispose of
  377. > window A. Now create a new window C. It does NOT get hilited, but it IS
  378. > active. [....]
  379.  
  380. > * Second bug:
  381. > Open a new window, A. Open a new window, B. Open a new window, C and
  382. > hide window B. Now show window B and hide window C. Now hide window
  383. > B, leaving only window A visible. Window A is NOT active and is NOT
  384. > hilited.  [....]
  385.  
  386. Here are my versions of the related routines.  These should fix the bugs 
  387. you saw.  Please let me know if these cause any problems.  I edited this
  388. a little to make the wrappng work better for the post - I may have 
  389. introduced typos.  Caveat Emptor.  If this code fails, I will refund
  390. your full purchase price.  :-P
  391.  
  392. pascal void ShowReferencedWindow(WindowRef windowToShow)
  393. {
  394.     WindowRef            frontNonFloatingWindow;
  395.     ActivateHandlerUPP    activateHandlerProc;
  396.     short                windowClass;
  397.     Boolean                windowIsInFront = false;
  398.     
  399.     if (GetWindowVisible(windowToShow) != false)
  400.         return;
  401.         
  402.     windowClass = GetWindowKind(windowToShow);
  403.     frontNonFloatingWindow = FrontNonFloatingWindow();
  404.     
  405.     // If the window we are showing will become frontdoc, deactivate
  406.     // former frontdoc, and activate new one.
  407.     
  408.     if (windowClass != kApplicationFloaterKind) 
  409.     {
  410.         if (IsInFrontOf(windowToShow,frontNonFloatingWindow))
  411.         {
  412.             if (frontNonFloatingWindow) 
  413.                 DeactivateWindow(frontNonFloatingWindow);
  414.             SetWindowHilite(windowToShow, true);
  415.             windowIsInFront = true;
  416.         }
  417.     }
  418.     else 
  419.     {
  420.     
  421.     // A floating window is about to be shown. 
  422.     // Make sure the windows in the window list
  423.     // are all in the right place.
  424.     
  425.         ValidateWindowList();
  426.         
  427.     // Check to see if a modal window is up 
  428.     // before trying to highlight it.
  429.     
  430.         frontNonFloatingWindow = FrontNonFloatingWindow();
  431.         if ((frontNonFloatingWindow != nil) &&
  432.             (frontNonFloatingWindow == (WindowRef) FrontWindow()) &&
  433.             (WindowIsModal(frontNonFloatingWindow)))
  434.             SetWindowHilite(windowToShow, false);
  435.         else 
  436.         {
  437.             SetWindowHilite(windowToShow, true);
  438.             windowIsInFront = true;
  439.         }
  440.     }
  441.     
  442.     // Show the window
  443.     
  444.     ShowHide((WindowPtr) windowToShow, true);
  445.     
  446.     // If this is the new frontmost document window 
  447.     // or a floating window, send it an activate event
  448.     
  449.     if (windowIsInFront) 
  450.     {
  451.         activateHandlerProc = GetActivateHandlerProc(windowToShow);
  452.         if (activateHandlerProc != nil)
  453.             CallActivateHandlerProc(activateHandlerProc, 
  454.                     windowToShow, kActivateWindow);
  455.     }
  456. }
  457.  
  458. pascal void HideReferencedWindow(WindowRef windowToHide)
  459. {
  460.     WindowRef            frontFloater;
  461.     WindowRef            frontNonFloater;
  462.     
  463.     // The original code here reorders windows in the window list
  464.     //  to make hidden windows swap places with the window behind
  465.     //  them if:
  466.     //  a) they are either the frontmost floater or frontmost doc;
  467.     //  b) there is a window of the same type behind them;
  468.     //  c) that window behind is visible
  469.     //  That didn't make a lot of sense to me, and it caused bugs,
  470.     //  so I've scrapped it and taken a simpler approach.    
  471.     
  472.     // Don't do anything if the window is already invisible.
  473.     
  474.     if (GetWindowVisible(windowToHide) == false)
  475.         return;
  476.     
  477.     // Get the first visible floating window, if any.
  478.     
  479.     frontFloater = (WindowRef) FrontWindow();
  480.     if (GetWindowKind(frontFloater) != kApplicationFloaterKind)
  481.         frontFloater = nil;
  482.         
  483.     // Get the first visible document window, if any.
  484.     
  485.     frontNonFloater = FrontNonFloatingWindow();
  486.     
  487.     // Hide the window.
  488.     
  489.     ShowHide((WindowPtr) windowToHide, false);
  490.  
  491.     // if we are hiding the frontmost doc window, activate the next
  492.     // frontmost doc window, if any are visible.
  493.     
  494.     if (windowToHide == frontNonFloater)
  495.     {
  496.         // now that we've hidden windowToHide, frontNonFloater will 
  497.         // be different
  498.         frontNonFloater = FrontNonFloatingWindow();
  499.         if (frontNonFloater)
  500.         {
  501.             ActivateWindow(frontNonFloater);
  502.         }
  503.     }
  504. }
  505.  
  506. Boolean IsInFrontOf(WindowRef win1, WindowRef win2)
  507. {
  508.     WindowRef    nextWindow = win1;
  509.  
  510.     //nil windows are always behind other windows
  511.     if (!win1) return false;  
  512.     
  513.     //other windows are always ahead of nil windows
  514.     if (!win2) return true; 
  515.     
  516.     //ok, so the programmer asked me a dumb question  
  517.     if (win1 == win2) return false;  
  518.     
  519.     while (nextWindow)
  520.     {
  521.         nextWindow = GetNextWindow(nextWindow);
  522.         if (nextWindow==win2) return true;
  523.     }
  524.     return false;
  525. }
  526.  
  527. - ------------------------------------------------------------------------
  528. Clap... Hop.... say "Kweepa".....
  529. - ------------------------------------------------------------------------
  530.  
  531. +++++++++++++++++++++++++++
  532.  
  533. >From Joe Francis <Joe.Francis@dartmouth.edu>
  534. Date: 31 May 1994 19:43:05 GMT
  535. Organization: Smooth Roo Software
  536.  
  537. Thomas Reed, reed@medicine.wustl.edu writes:
  538. > On an aside, does anyone know if you can use this code to create a
  539. > floating window that will float over ALL windows at ALL times?  i.e. -
  540. > even when other apps are in the front, the window will float over ALL
  541. > windows?
  542.  
  543. The "develop" floating windows code (by Dean Yu) acheives it's floating
  544. by juggling windows around in the window list.  The window list, though,
  545. is process specific.  Other applications windows are not in the window
  546. list your app sees when it is in the forground.  So the answer is no,
  547. the develop code can not be used to do what you want.
  548.  
  549. - ------------------------------------------------------------------------
  550. No matter how subtle the wizard, a knife between the shoulder blades
  551. will seriously cramp his style.
  552. - ------------------------------------------------------------------------
  553.  
  554. +++++++++++++++++++++++++++
  555.  
  556. >From mxmora@unix.sri.com (Matt Mora)
  557. Date: 1 Jun 94 15:34:17 GMT
  558. Organization: SRI International, Menlo Park, CA
  559.  
  560. In article <1994May31.191735.10959@gallant.apple.com> Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  561. >Thomas Reed, reed@medicine.wustl.edu writes:
  562.  
  563. >Needless to say I'd recommend (A), even though I hear there are some weird
  564. >issues associated with running TSM windows. Donald Brown of CE Software wrote
  565. >a little demo app that does this for last years' MacHack; perhaps the source
  566. >code is around somewhere.
  567.  
  568.  
  569. Matt Slot just posted some code to do the floating windows stuff to 
  570. a.s.m.
  571.  
  572.  
  573. Xavier
  574.  
  575.  
  576. -- 
  577. ___________________________________________________________
  578. Matthew Xavier Mora                       Matt_Mora@sri.com
  579. SRI International                       mxmora@unix.sri.com
  580. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  581.  
  582. ---------------------------
  583.  
  584. >From dubois@uakari.primate.wisc.edu (Paul DuBois)
  585. Subject: Detecting Universal Headers?
  586. Date: 13 May 1994 09:59:53 -0500
  587. Organization: Castra Parvulorum
  588.  
  589. Is there a way I can tell whether the universal headers are being
  590. used, e.g., to do this:
  591.  
  592. #if universalheaders
  593.     do this
  594. #else
  595.     do this instead
  596. #endif
  597.  
  598. -- 
  599. Paul DuBois
  600. dubois@primate.wisc.edu
  601.  
  602. +++++++++++++++++++++++++++
  603.  
  604. >From dmg@dcs.ed.ac.uk (Dominik Gamble)
  605. Date: Mon, 16 May 1994 13:58:08 GMT
  606. Organization: Department of Computer Science, University of Edinburgh
  607.  
  608. In article <2r04l9INN1r9@uakari.primate.wisc.edu>, dubois@uakari.primate.wisc.edu (Paul DuBois) writes:
  609. > Is there a way I can tell whether the universal headers are being
  610. > used, e.g., to do this:
  611. > #if universalheaders
  612. >     do this
  613. > #else
  614. >     do this instead
  615. > #endif
  616.  
  617. As far as I know,
  618.  
  619. #ifdef USES68KINLINES
  620.     /* universal headers present */
  621. #else
  622.     /* universal headers absent */
  623. #endif
  624.  
  625. should work. (At least as far as you know you are compiling
  626. for a 680x0).
  627.  
  628.  
  629. +++++++++++++++++++++++++++
  630.  
  631. >From dean@genmagic.com (Dean Yu)
  632. Date: 18 May 1994 18:01:57 GMT
  633. Organization: General Magic, Inc.
  634.  
  635. In article <CpwEsx.4zz@dcs.ed.ac.uk>, dmg@dcs.ed.ac.uk (Dominik Gamble)
  636. wrote:
  637.  
  638. > In article <2r04l9INN1r9@uakari.primate.wisc.edu>, dubois@uakari.primate.wisc.edu (Paul DuBois) writes:
  639. > > Is there a way I can tell whether the universal headers are being
  640. > > used, e.g., to do this:
  641. > > 
  642. > > #if universalheaders
  643. > >     do this
  644. > > #else
  645. > >     do this instead
  646. > > #endif
  647. > As far as I know,
  648. > #ifdef USES68KINLINES
  649. >     /* universal headers present */
  650. > #else
  651. >     /* universal headers absent */
  652. > #endif
  653.  
  654.   This will work for now, but USES68KINLINES was meant to mean that system
  655. software prototypes are defined using inlined 680x0 instructions (like
  656. A-Traps, and possible some register moving instructions). If Apple ever
  657. moves the system over to shared libraries, then USES68KINLINES would be 0,
  658. even though Universal headers might be present.
  659.   Oh, wait. You used #ifdef, not #if. Never mind.
  660.   At any rate, the Universal Headers comes with a file called
  661. ConditionalMacros.h, which has all the compile time switches that makes the
  662. headers universal. I can't remember if anything specifically about
  663. universal headres was defined in there, but that's the place to look.
  664.  
  665. -- Dean Yu
  666.    Negative Ethnic Role Model
  667.    General Magic, Inc.
  668.  
  669. +++++++++++++++++++++++++++
  670.  
  671. >From tdevon@aol.com (TDevon)
  672. Date: 30 May 1994 04:57:02 -0400
  673. Organization: America Online, Inc. (1-800-827-6364)
  674.  
  675. In article <dean-180594105746@dean_yu.genmagic.com>,
  676. dean@genmagic.com (Dean Yu) writes:
  677.  
  678. I've been using #ifdef's with 'USESROUTINEDESCRIPTORS' but you could
  679. check for '__MIXEDMODE__' as well since that file only exists in the
  680. Universal Headers.  Such a shame that Apple went to all the work in
  681. creating the Universal Headers and they didn't give us defined way to
  682. detect whether they were present or not.  slap, slap!
  683.  
  684. dEVoN
  685.  
  686. ---------------------------
  687.  
  688. >From Adrian C Ruigrok <adrianr@wimsey.com>
  689. Subject: Enumerating messages from PowerTalk
  690. Date: 26 May 1994 23:12:13 GMT
  691. Organization: Ruigrok Innovations Inc.
  692.  
  693. Has anyone figured out how to enumerate AOCE folder?
  694.  
  695. The documentation seems to imply that all you can do
  696. is open a letter that was passed to you when someone 
  697. double clicked on it in the compound mailbox.  You can
  698. also get the next unread letter in the mailbox.
  699.  
  700. But how do you go back the the previous message.  Or
  701. even more involved, how could you show the user a list
  702. of messages in the compound mailbox:  Both the inbox and
  703. the outbox.
  704.  
  705. It looks like the way to do it is with the LetterSpec, but 
  706. the docs say that structure is private and there are no
  707. functions to help you create one.
  708.  
  709. Perhaps the answer is that you should not be creating a list
  710. of letters, but to have to go back the the finder every time 
  711. to browse through your letters is tedious at best.
  712.  
  713. Adrian
  714.  
  715. +++++++++++++++++++++++++++
  716.  
  717. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  718. Date: Fri, 27 May 1994 15:42:17 GMT
  719. Organization: Sexton Software
  720.  
  721. In article <2s3acd$29d@wolfe.wimsey.com> Adrian C Ruigrok,
  722. adrianr@wimsey.com writes:
  723. >Perhaps the answer is that you should not be creating a list
  724. >of letters, but to have to go back the the finder every time 
  725. >to browse through your letters is tedious at best.
  726.  
  727. That seems to be exactly what is intended by Mr. Sidhu. There was a lot
  728. of flak on this particular topic some time back and I've heard no
  729. indication that Apple has changed its position. Sorry I can't provide
  730. useful information (try to hack the external file system?) except to say
  731. that others have reached the same conclusion.
  732. Steve Bryan                       sbryan@maroon.tc.umn.edu
  733. Sexton Software                   CompuServe: 76545,527
  734. Minneapolis, MN                   fax: (612) 929-1799
  735.  
  736. +++++++++++++++++++++++++++
  737.  
  738. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  739. Date: 30 May 94 17:02:26 +1200
  740. Organization: University of Waikato, Hamilton, New Zealand
  741.  
  742. In article <2s3acd$29d@wolfe.wimsey.com>, Adrian C Ruigrok <adrianr@wimsey.com> writes:
  743. > Has anyone figured out how to enumerate AOCE folder?
  744. >
  745. > The documentation seems to imply that all you can do
  746. > is open a letter that was passed to you when someone
  747. > double clicked on it in the compound mailbox.  You can
  748. > also get the next unread letter in the mailbox.
  749. >
  750. > But how do you go back the the previous message.  Or
  751. > even more involved, how could you show the user a list
  752. > of messages in the compound mailbox:  Both the inbox and
  753. > the outbox.
  754. >
  755. > It looks like the way to do it is with the LetterSpec, but
  756. > the docs say that structure is private and there are no
  757. > functions to help you create one.
  758. >
  759. > Perhaps the answer is that you should not be creating a list
  760. > of letters, but to have to go back the the finder every time
  761. > to browse through your letters is tedious at best.
  762.  
  763. I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  764. He said there *is* a mail API that would allow you to do all this, but it
  765. wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  766. it public. He promised that they would do so in a future version.
  767.  
  768. In the meantime, you could try asking DTS if they'll give you information about
  769. the unsupported API. I understand some vendors are already working with this.
  770.  
  771. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  772. Info & Tech Services Division              fax: +64-7-838-4066
  773. University of Waikato            electric mail: ldo@waikato.ac.nz
  774. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  775.  
  776. +++++++++++++++++++++++++++
  777.  
  778. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  779. Date: 30 May 1994 10:46:04 GMT
  780. Organization: Microplex Pty Ltd
  781.  
  782. Lawrence D'Oliveiro, Waikato University (ldo@waikato.ac.nz) wrote:
  783. : In article <2s3acd$29d@wolfe.wimsey.com>, Adrian C Ruigrok <adrianr@wimsey.com> writes:
  784. : > Has anyone figured out how to enumerate AOCE folder?
  785. : >
  786. : > The documentation seems to imply that all you can do
  787. : > is open a letter that was passed to you when someone
  788. : > double clicked on it in the compound mailbox.  You can
  789. : > also get the next unread letter in the mailbox.
  790. : >
  791. : > But how do you go back the the previous message.  Or
  792. : > even more involved, how could you show the user a list
  793. : > of messages in the compound mailbox:  Both the inbox and
  794. : > the outbox.
  795. : >
  796. : > It looks like the way to do it is with the LetterSpec, but
  797. : > the docs say that structure is private and there are no
  798. : > functions to help you create one.
  799. : >
  800. : > Perhaps the answer is that you should not be creating a list
  801. : > of letters, but to have to go back the the finder every time
  802. : > to browse through your letters is tedious at best.
  803.  
  804. : I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  805. : He said there *is* a mail API that would allow you to do all this, but it
  806. : wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  807. : it public. He promised that they would do so in a future version.
  808.  
  809. : In the meantime, you could try asking DTS if they'll give you information about
  810. : the unsupported API. I understand some vendors are already working with this.
  811.  
  812. I also have heard the same story. However, I have "discovered" that the 
  813. in tray can be enumerated at a low level using the IPM calls. The queue 
  814. to access is called In_Tray or something (I can't remember the exact 
  815. name, the code is at work and I'm at home at present). You can read mail 
  816. this way, but you can't mark it as read, or tell whether it was read 
  817. before. Also, the mail MUST be present on the local machine. If it is on 
  818. a server, you will have to discover the queue name and address for yourself!
  819.  
  820. In the meantime, we have an oustanding DTS request for the private API. 
  821. Unfortunately, I expect this to be subject to an NDA :(
  822.  
  823. If anyone needs more details on the above I can probably post it from 
  824. work tomorrow.
  825.  
  826. - ---
  827. Steve Coy
  828. Resolve Software (WA) Pty Ltd
  829.  
  830.  
  831. +++++++++++++++++++++++++++
  832.  
  833. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  834. Date: Tue, 31 May 1994 19:24:17 GMT
  835. Organization: Apple Computer
  836.  
  837. Lawrence D'Oliveiro, ldo@waikato.ac.nz writes:
  838. > I asked an Apple guy about this at WWDC (sorry, I didn't get his name).
  839. > He said there *is* a mail API that would allow you to do all this, but it
  840. > wasn't sufficiently tested for PowerTalk 1.0, which is why they didn't make
  841. > it public. He promised that they would do so in a future version.
  842. > In the meantime, you could try asking DTS if they'll give you information
  843. about
  844. > the unsupported API. I understand some vendors are already working with
  845. this.
  846.  
  847. Beyond's "PowerRules" provides a suite of events for accessing the In Tray.
  848. You can enumerate the letters, examine info like senders or date sent, all
  849. from Apple events. This implies that they're using this private API, and also
  850. that other apps could get this functionality by talking to PowerRules.
  851.  
  852. Unfortunately I have to say that the version I used (1.0D, I think) was
  853. really buggy. Their Apple Event support seems flaky in the extreme, and it
  854. was only with difficulty that I could get anything to work; even then, most
  855. of the time it either ignored incoming mail or returned mysterious error
  856. codes when running my agent scripts. If they could only make the thing more
  857. solid it'd be terrific.
  858.  
  859. --Jens Alfke
  860.   jens_alfke@powertalk              Rebel girl, rebel girl,
  861.             .apple.com              Rebel girl you are the queen of my world
  862.  
  863. ---------------------------
  864.  
  865. >From hoyer@cc.Helsinki.FI (Paul Hoyer)
  866. Subject: MicroSeconds trap # and arguments?
  867. Date: 25 May 1994 22:43:14 +0300
  868. Organization: University of Helsinki
  869.  
  870. I know there was a thread a while ago concerning the MicroSeconds trap,
  871. but I didn't follow c.s.m.p closely enough then... So sorry if I'm
  872. asking for information I might have got from that thread!
  873.  
  874. I'd like to use the MicroSeconds() trap to measure the speed of my code,
  875. but since Think C v5.0 doesn't seem to know about the trap I need the
  876. trap number and how to call if from assembly. I assume the trap is
  877. implemented in Sys. 7.1?
  878.  
  879. It's probably documented in IM-6 somewhere, but since I don't own it
  880. (I'm just a poor student), I'd appreciate it if somebody could simply
  881. e-mail me the info.
  882.  
  883. Thanks in advance!!!
  884.  
  885. -P. Hoyer <hoyer@cc.helsinki.fi>
  886.  
  887. +++++++++++++++++++++++++++
  888.  
  889. >From olmsted@cs.ucdavis.edu (Bret Olmsted)
  890. Date: Wed, 25 May 1994 20:15:23 GMT
  891. Organization: University of California, Davis
  892.  
  893. Paul Hoyer (hoyer@cc.Helsinki.FI) wrote:
  894. : I'd like to use the MicroSeconds() trap to measure the speed of my code,
  895. : but since Think C v5.0 doesn't seem to know about the trap I need the
  896. : trap number and how to call if from assembly. I assume the trap is
  897. : implemented in Sys. 7.1?
  898.  
  899. Here is some code that does just the job:
  900.  
  901. TMTask             task;
  902.  
  903. static void start_timer(void)        /* Start measuring elapsed time. */
  904.   {
  905.     task.qLink = NULL;
  906.     task.qType = 0;
  907.     task.tmAddr = 0;
  908.     task.tmCount = 0;
  909.     InsTime((QElemPtr) &task);
  910.     PrimeTime((QElemPtr) &task, 0x80000000);
  911.   }
  912.  
  913. static long stop_timer(void)        /* Stop measuring elapsed time. */
  914.   {
  915.     RmvTime((QElemPtr) &task);
  916.     return task.tmCount - 0x80000000;    /* return time elapsed. */
  917.   }
  918.  
  919.  
  920. Hope that helps.
  921.  
  922. Bret Olmsted
  923. olmsted@cs.ucdavis.edu
  924.  
  925.  
  926. u
  927.  
  928.  
  929. +++++++++++++++++++++++++++
  930.  
  931. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  932. Date: 31 May 94 10:36:01 +1200
  933. Organization: University of Waikato, Hamilton, New Zealand
  934.  
  935. In article <2s09oi$4ga@kruuna.Helsinki.FI>, hoyer@cc.Helsinki.FI (Paul Hoyer) writes:
  936. >
  937. > I'd like to use the MicroSeconds() trap to measure the speed of my code,
  938. > but since Think C v5.0 doesn't seem to know about the trap I need the
  939. > trap number and how to call if from assembly. I assume the trap is
  940. > implemented in Sys. 7.1?
  941. >
  942. > It's probably documented in IM-6 somewhere...
  943.  
  944. No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  945. I gather it has since worked its way into Apple's standard interfaces. Here's
  946. one way you can call it:
  947.  
  948.     PROCEDURE MicroSeconds64
  949.       (
  950.     VAR Result : Comp
  951.       );
  952.       (* returns the full 64 bits of a microsecond clock. *)
  953.  
  954.     CODE
  955.         0A193H,        (* _MicroSeconds *)
  956.         0225FH,        (* move.l (sp)+, a1 *)
  957.         022C8H,        (* move.l a0, (a1)+ *)
  958.         022C0H;        (* move.l d0, (a1)+ *)
  959.  
  960. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  961. Info & Tech Services Division              fax: +64-7-838-4066
  962. University of Waikato            electric mail: ldo@waikato.ac.nz
  963. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  964.  
  965. +++++++++++++++++++++++++++
  966.  
  967. >From sobiloff (Blake Sobiloff)
  968. Date: Tue, 31 May 1994 11:36:26 -0400
  969. Organization: Lab for Automation Psychology
  970.  
  971. In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  972. (Lawrence D'Oliveiro, Waikato University) wrote:
  973.  
  974. > No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  975. > I gather it has since worked its way into Apple's standard interfaces. Here's
  976. > one way you can call it:
  977. [...]
  978.  
  979. Or, if you have the Universal Headers, its trap is included in <Traps.h>.
  980. -- 
  981. Blake Sobiloff <sobiloff@mail.lap.umd.edu> | University of Maryland
  982. Laboratory for Automation Psychology       | College Park, MD  20742-4411
  983. Department of Psychology                   | 301/405-5936 (Voice)
  984.               Ayrton Senna de Silva, RIP. (May 1, 1994)
  985.  
  986. +++++++++++++++++++++++++++
  987.  
  988. >From afcjlloyd@aol.com (AFC JLloyd)
  989. Date: 31 May 1994 18:36:01 -0400
  990. Organization: America Online, Inc. (1-800-827-6364)
  991.  
  992. In article <sobiloff-310594113627@dataranch.lap.umd.edu>, sobiloff
  993. (Blake Sobiloff) writes:
  994.  
  995. >In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  996. >(Lawrence D'Oliveiro, Waikato University) wrote:
  997. >
  998. >> No, it's not. It first turned up in some Sound Manager 3.0 sample
  999. code, and
  1000. >> I gather it has since worked its way into Apple's standard
  1001. interfaces. Here's
  1002. >> one way you can call it:
  1003. >[...]
  1004. >
  1005. >Or, if you have the Universal Headers, its trap is included in
  1006. <Traps.h>.
  1007.  
  1008. Or even better, if you have the Universal Headers it is defined in
  1009. <Timer.h>:
  1010.  
  1011. extern pascal void Microseconds(UnsignedWide *microTickCount)
  1012.  FOURWORDINLINE(0xA193, 0x225F, 0x22C8, 0x2280);
  1013.  
  1014. I have done some experimenting with this trap today and noticed that
  1015. it seems to be true microseconds.  From various documentation that I
  1016. have seen the Time Manager is based on a VIA timer that operates at
  1017. 783360 hz, but the values returned by Microseconds are clearly much
  1018. closer to 1000000 hz.  Perhaps this has been mentioned earlier in
  1019. this thread and I missed it, but I assume this trap is not supported
  1020. on all configurations of hardware/software.  I believe it was
  1021. mentioned earlier that QuickTime relies on this trap.  Can I assume
  1022. that any configuration of hardware/software that supports QuickTime
  1023. will support this trap?
  1024.  
  1025. Jim Lloyd
  1026. afcjlloyd@aol.com
  1027.  
  1028.  
  1029. +++++++++++++++++++++++++++
  1030.  
  1031. >From dean@genmagic.com (Dean Yu)
  1032. Date: 1 Jun 1994 03:16:08 GMT
  1033. Organization: General Magic, Inc.
  1034.  
  1035. In article <1994May31.103601.29104@waikato.ac.nz>, ldo@waikato.ac.nz
  1036. (Lawrence D'Oliveiro, Waikato University) wrote:
  1037.  
  1038. > In article <2s09oi$4ga@kruuna.Helsinki.FI>, hoyer@cc.Helsinki.FI (Paul Hoyer) writes:
  1039. > >
  1040. > > I'd like to use the MicroSeconds() trap to measure the speed of my code,
  1041. > > but since Think C v5.0 doesn't seem to know about the trap I need the
  1042. > > trap number and how to call if from assembly. I assume the trap is
  1043. > > implemented in Sys. 7.1?
  1044. > >
  1045. > > It's probably documented in IM-6 somewhere...
  1046. > No, it's not. It first turned up in some Sound Manager 3.0 sample code, and
  1047. > I gather it has since worked its way into Apple's standard interfaces. Here's
  1048. > one way you can call it:
  1049.  
  1050.   Actually, I believe it first came out with QuickTime. I seem to recall
  1051. fixing a bug in 7.1 where the value returned by Microseconds would drift
  1052. after a while, so it's been around for at least that long. Whether it's
  1053. been public since then is a different story...
  1054.  
  1055. -- Dean Yu
  1056.    Negative Ethnic Role Model
  1057.    General Magic, Inc.
  1058.  
  1059. ---------------------------
  1060.  
  1061. >From st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith)
  1062. Subject: Ok, where's my Quickdraw globals?  (Help!)
  1063. Date: Sat, 21 May 1994 06:01:36 GMT
  1064. Organization: Drexel University
  1065.  
  1066.    We just got our copy of CodeWarrior Gold today, and I've been feverishly
  1067. working to port a few thousand lines of C++ code from Symantec C++.
  1068.  
  1069.    For the most part, converting to the PPC seems to have been easy.  I was
  1070. able to get everything to compile and link after some fooling around.
  1071.  
  1072.    But I'm having a problem, and I'm familiar with it, and know it's been
  1073. raised before, but never paid too much attention.
  1074.  
  1075.    I specifically use some QuickDraw globals such as "thePort" and
  1076. "screenBits."  That's never been a problem with Symantec C++.
  1077.  
  1078.    But CodeWarrior doesn't like them.
  1079.  
  1080. I note the following structure (defined in good ol' Quickdraw.h):
  1081.  
  1082. - --
  1083. struct QDGlobals {
  1084.     char                        privates[76];
  1085.     long                        randSeed;
  1086.     BitMap                    screenBits;
  1087.     Cursor                    arrow;
  1088.     Pattern                    dkGray;
  1089.     Pattern                    ltGray;
  1090.     Pattern                    gray;
  1091.     Pattern                    black;
  1092.     Pattern                    white;
  1093.     GrafPtr                    thePort;
  1094. };
  1095. #if defined(powerc) || defined(__powerc)
  1096. #pragma options align=reset
  1097. #endif
  1098.  
  1099. typedef struct QDGlobals QDGlobals;
  1100. - --
  1101.  
  1102.    Obviously, this is what I'm looking for.  First question: is this the
  1103. method we're supposed to use now to get at things such as thePort?
  1104.  
  1105.    And the most important question: HOW DO I FILL THIS STRUCTURE?  I'm
  1106. assuming there must be an easy way; I can't find it, and I can't find any
  1107. useful mention of it in docs anywhere.
  1108.  
  1109.    I feel like I've been sleeping and missed the boat on this one.
  1110. I know some yechy ways of getting at screenBits and thePort, but would like
  1111. to avoid that, since I'm assuming there's a much easier way.
  1112.  
  1113.    Any help would be appreciated.
  1114.  
  1115.    Other than that, so far I'm pleased with CodeWarrior.  Neat About
  1116. boxes.  :)  I'd have to echo another poster's comments on the docs, though:
  1117. I hate Apple's DocViewer.  I love Think Reference.
  1118.  
  1119.    Also, the editor seems sluggish.  I assume this is because of its added
  1120. "functionality" such as colorizing different types of text.  (Then again,
  1121. I'm running on an old, slow IIfx..  Sigh.)
  1122.  
  1123. Thanks in advance for (prompt) help..  I'd like to get this thing ported by
  1124. Sunday for an Open House we're having.
  1125.  
  1126. - Scott
  1127.  
  1128. - -
  1129. M. Scott Smith  (umsmith@mcs.drexel.edu)
  1130.  
  1131.   Math and Computer Science, Drexel University
  1132.  
  1133.   Mac developer.  Student.  Ski bum.  (But all the snow melted..  Sniff.)
  1134.  
  1135.  
  1136. +++++++++++++++++++++++++++
  1137.  
  1138. >From dan694356@aol.com (Dan 694356)
  1139. Date: 21 May 1994 03:03:14 -0400
  1140. Organization: America Online, Inc. (1-800-827-6364)
  1141.  
  1142. You need to allocate storage for qd...
  1143.  
  1144. #ifdef powerc
  1145. QDGlobals qd;
  1146. #endif
  1147.  
  1148. ... somewhere in your code, it's not in the PPC libraries (don't know
  1149. why, Apple just left it out).  If you've gotten used to doing just
  1150. 'thePort' or 'screenBits' rather than 'qd.thePort' and
  1151. 'qd.screenBits', now's as good a time as any to get out of that
  1152. habit, since it doesn't work in the new compilers either. :-)
  1153.  
  1154. - Dan
  1155.  
  1156. +++++++++++++++++++++++++++
  1157.  
  1158. >From mwron@aol.com (MW Ron)
  1159. Date: 21 May 1994 12:22:14 -0400
  1160. Organization: America Online, Inc. (1-800-827-6364)
  1161.  
  1162. In article <Cq522o.CKz@Dunx1.OCS.Drexel.Edu>,
  1163. st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith) writes:
  1164.  
  1165. >> I specifically use some QuickDraw globals such as "thePort" and
  1166. "screenBits."  That's never been a problem with Symantec C++.
  1167.  
  1168.   This is not a Symantec vs CW item, it is a change Apple made to
  1169. minimaze global namespace cluttering.  A few years ago Apple decided
  1170. to encapsulate the variables called the QuickDraw globals that are
  1171. referenced from A5 and include thePort and screenBits in a structure
  1172. called qd. You can find them listed in the QuickDraw.h header file.
  1173. This new way also allows the compiler to handle quickdraw globals
  1174. without any special code on non-68k Macs.
  1175.     To access your global QuickDraw Variables, simply use
  1176. qd.<variableName> to access them as a structure member.
  1177.  
  1178. Ron Liechty
  1179. mwron@aol.com
  1180. Metrowerks Inc.
  1181.  
  1182. +++++++++++++++++++++++++++
  1183.  
  1184. >From mxmora@unix.sri.com (Matt Mora)
  1185. Date: 23 May 1994 10:30:07 -0700
  1186. Organization: SRI International, Menlo Park, CA
  1187.  
  1188. In article <Cq522o.CKz@Dunx1.OCS.Drexel.Edu> st917wbh@dunx1.ocs.drexel.edu (M. Scott Smith) writes:
  1189. >   We just got our copy of CodeWarrior Gold today, and I've been feverishly
  1190. >working to port a few thousand lines of C++ code from Symantec C++.
  1191. >
  1192. >   For the most part, converting to the PPC seems to have been easy.  I was
  1193. >able to get everything to compile and link after some fooling around.
  1194. >
  1195. >   But I'm having a problem, and I'm familiar with it, and know it's been
  1196. >raised before, but never paid too much attention.
  1197. >
  1198. >   I specifically use some QuickDraw globals such as "thePort" and
  1199. >"screenBits."  That's never been a problem with Symantec C++.
  1200.  
  1201. >struct QDGlobals {
  1202.  
  1203. You need to add
  1204.  
  1205.  
  1206. QDGlobals qd;
  1207.  
  1208. to your code to create the global variable. the you call InitGraf
  1209. passing the global &qd.thePort to Initgraf.
  1210.  
  1211. Xavier
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217. -- 
  1218. ___________________________________________________________
  1219. Matthew Xavier Mora                       Matt_Mora@sri.com
  1220. SRI International                       mxmora@unix.sri.com
  1221. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  1222.  
  1223. +++++++++++++++++++++++++++
  1224.  
  1225. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1226. Date: Thu, 26 May 1994 22:43:37 GMT
  1227. Organization: Apple Computer
  1228.  
  1229. Matt Mora, mxmora@unix.sri.com writes:
  1230. > You need to add
  1231. > QDGlobals qd;
  1232. > to your code to create the global variable. the you call InitGraf
  1233. > passing the global &qd.thePort to Initgraf.
  1234.  
  1235. Huh? In CodeWarrior? I've never needed to do this. As far as I can tell, qd
  1236. is automatic; it's defined in the runtime library or somewhere like that.
  1237.  
  1238. --Jens Alfke
  1239.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1240.             .apple.com              Rebel girl you are the queen of my world
  1241.  
  1242. +++++++++++++++++++++++++++
  1243.  
  1244. >From paulw@crl.com (Paul Winterrowd)
  1245. Date: 27 May 1994 09:32:12 -0700
  1246. Organization: CRL Dialup Internet Access    (415) 705-6060  [login: guest]
  1247.  
  1248. Jens Alfke (jens_alfke@powertalk.apple.com) wrote:
  1249. : Matt Mora, mxmora@unix.sri.com writes:
  1250. : > You need to add
  1251. : > QDGlobals qd;
  1252. : > to your code to create the global variable. the you call InitGraf
  1253. : > passing the global &qd.thePort to Initgraf.
  1254.  
  1255. : Huh? In CodeWarrior? I've never needed to do this. As far as I can tell, qd
  1256. : is automatic; it's defined in the runtime library or somewhere like that.
  1257.  
  1258. : --Jens Alfke
  1259. :   jens_alfke@powertalk              Rebel girl, rebel girl,
  1260. :             .apple.com              Rebel girl you are the queen of my world
  1261.  
  1262. Check out the file MacHeaderPPC (or MacHeader68K if you are compiling 68k code)
  1263. and I believe that's where it is defined.  The really nice part about it is
  1264. you can change the precompiled header!  
  1265.  
  1266. paulw@crl.com
  1267. -- 
  1268. - ---------------------------------------------------------------
  1269. I only speak for myself.  
  1270.  
  1271.  
  1272. +++++++++++++++++++++++++++
  1273.  
  1274. >From bell@apple.com (Mike Bell)
  1275. Date: Tue, 31 May 1994 18:09:32 GMT
  1276. Organization: Apple Computer, Inc.
  1277.  
  1278. In article <2s57ac$eap@crl.crl.com>, paulw@crl.com (Paul Winterrowd) writes:
  1279. > Path: gallant.apple.com!murky.apple.com!apple.com!olivea!decwrl!nntp.
  1280. > crl.com!crl.crl.com!not-for-mail From: paulw@crl.com (Paul Winterrowd) 
  1281. > Newsgroups: comp.sys.mac.programmer 
  1282. > Subject: Re: Ok, where's my Quickdraw globals?  (Help!) 
  1283. > Date: 27 May 1994 09:32:12 -0700 
  1284. > Organization: CRL Dialup Internet Access    (415) 705-6060  [login: 
  1285. > guest] Lines: 23 
  1286. > Message-ID: <2s57ac$eap@crl.crl.com> 
  1287. > References: <Cq522o.CKz@Dunx1.OCS.Drexel.Edu> <2rqp6v$1oe@unix.sri.
  1288. > com> <1994May26.224337.8856@gallant.apple.com> NNTP-Posting-Host: crl.
  1289. > com 
  1290. > X-Newsreader: TIN [version 1.2 PL2] 
  1291. > Jens Alfke (jens_alfke@powertalk.apple.com) wrote: 
  1292. > : Matt Mora, mxmora@unix.sri.com writes: 
  1293. > : > You need to add 
  1294. > : > QDGlobals qd; 
  1295. > : > to your code to create the global variable. the you call 
  1296. > InitGraf : > passing the global &qd.thePort to Initgraf. 
  1297. > : Huh? In CodeWarrior? I've never needed to do this. As far as I can 
  1298. > tell, qd : is automatic; it's defined in the runtime library or 
  1299. > somewhere like that. 
  1300. > : --Jens Alfke 
  1301. > :   jens_alfke@powertalk              Rebel girl, rebel girl, 
  1302. > :             .apple.com              Rebel girl you are the queen of 
  1303. > my world 
  1304. > Check out the file MacHeaderPPC (or MacHeader68K if you are 
  1305. > compiling 68k code) and I believe that's where it is defined.  The 
  1306. > really nice part about it is you can change the precompiled header!  
  1307. > paulw@crl.com 
  1308. > -- 
  1309. > ----------------------------------------------------------------- 
  1310. > I only speak for myself.  
  1311. >  
  1312.  
  1313.  
  1314. As Matt mentioned, you need to define your own QuickDraw globals if you are 
  1315. using the Apple PowerMacintosh development tools.  The CodeWarrior stuff 
  1316. defines it for you, but this is build system dependent.
  1317.  
  1318.     -Mike
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326. ---------------------------
  1327.  
  1328. >From timmyd@netcom.com (Tim DeBenedictis)
  1329. Subject: Symantec C++ 7.0- any good?
  1330. Date: Sun, 29 May 1994 18:04:06 GMT
  1331. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1332.  
  1333. I'm trying to decide between upgrading from THINK C 5.0.4 to Symantec C++
  1334. 7.0 or CodeWarrior.  Given that I've got a lot of code committed to THINK/
  1335. Symantec, is it worth switching to MetroWerks?  I've heard that Sym C++ 6.0
  1336. was so buggy as to be practically useless.  Is 7.0 decent?  Also, can I
  1337. compile native PPC apps with Symantec?  (I don't have a PPC yet, but I
  1338. may in the not so distant future.)  I also don't want to give up 50
  1339. megs of hard drive space to a compiler... which package is smaller?
  1340.  
  1341.  
  1342. Any comments greatly appreciated,
  1343.  
  1344. Tim DeBenedictis
  1345.  
  1346. PS please send e-mail, since I don't read this group often.
  1347.  
  1348.  
  1349. +++++++++++++++++++++++++++
  1350.  
  1351. >From nick@pitt.edu ( nick.c )
  1352. Date: Mon, 30 May 94 12:29:40 GMT
  1353. Organization: University of Pittsburgh
  1354.  
  1355. In Article <timmydCqKsuv.6vw@netcom.com>, timmyd@netcom.com (Tim
  1356. DeBenedictis) wrote:
  1357.  
  1358. >I'm trying to decide between upgrading from THINK C 5.0.4 to Symantec C++
  1359. >7.0 or CodeWarrior.  Given that I've got a lot of code committed to THINK/
  1360. >Symantec, is it worth switching to MetroWerks?  I've heard that Sym C++ 6.0
  1361. >was so buggy as to be practically useless.  Is 7.0 decent?  Also, can I
  1362. >compile native PPC apps with Symantec?  (I don't have a PPC yet, but I
  1363. >may in the not so distant future.)  I also don't want to give up 50
  1364. >megs of hard drive space to a compiler... which package is smaller?
  1365.  
  1366.  
  1367.    I haven't tried CodeWarrior yet (have thought about it), but 
  1368.      SC++ 7.02 seems pretty stable to me.  Here's some info I think 
  1369.      is important:
  1370.  
  1371.     - SC++ takes up about 17 MB HD space (full installation + 7.02 updated),
  1372.        while CodeWarrior takes up 6 MB for C/C++ (with another 8 MB for
  1373.        class library: total 14 MB) - ie both seem to be about the same.
  1374.  
  1375.     - With SC++ you have to pay extra to get a "cross platform" kit 
  1376.        from symantec - and I'm not really clear if this includes a PPC 
  1377.        compiler.  I don't think it does.  CodeWarrior gold includes 
  1378.        a PPC compiler and runs native.  No version of SC++ runs native yet.
  1379.  
  1380.     - If your code doesn't use TCL it should be portable to CodeWarrrior.
  1381.       
  1382.     - MetroWerks seems to have the best customer support.  They don't
  1383.        charge you for it (Symantec does after 30 days or so), they give you
  1384.        three free updates (Symantec has started something like this, but
  1385.        again you have to subscrivbe - ie pay - for it), and their guys
  1386.        seem to pay more attention to this newsgroup (no slight intended 
  1387.        to those folks from symantec who are here).
  1388.  
  1389.     - CodeWarrior is only available on CD.  For me this is a plus (I like
  1390.        CD's) - but if you don't have a drive yet this will be an issue.
  1391.  
  1392.     - TPM w/out VA can run in about 2.5 MB of ram.  I don't know how much
  1393.        CodeWarrior wants.
  1394.   
  1395.     - Both are compatible with other development tools like Think Reference
  1396.        (a must have in my book), Object Master (something I'm really
  1397.        getting addicted to), Alpha or BBedit, etc.
  1398.  
  1399.     - There is an established base of literature and example code out there
  1400.        specific for symantec. (eg. Dave Mark's Books, Sydow's Book,
  1401.        and guestimate >70% of shareware was written with Symantec's stuff). 
  1402.  
  1403.  
  1404.     I'm kind of new to all this (been at it about a year), so for me the
  1405.       last point is pretty important.  CodeWarrior is coming on strong,
  1406.       and I don't doubt that in another year there will be a wealth of
  1407.       software and literature out there written in/for CodeWarrior.
  1408.       For now, I'm going to stick with Symantec, and if other folks are
  1409.       just getting started I'd recommend same.  If you're familiar with
  1410.       the toolbox, have C or C++ down, and are generally a mature developer
  1411.       CodeWarrior seems to be the best deal.  I figure by the time I get
  1412.       there I'll be able to switch over fairly easy, or perhaps Symantec
  1413.       will come back strong with a packaged PPC compiler, a native
  1414.       environment, maybe a faster compiler, and (on my wish list) better
  1415.       documentation of TCL (sorry guys - I still can't make heads or 
  1416.       tails out of it... still trying).  Anyway, hope the info helps and 
  1417.       take the opinions with a grain of salt - both are good products.
  1418.  
  1419.                                                 -- nick
  1420.  
  1421.  
  1422.    BTW - has someone put together a SC++ vs CodeWarrior FAQ yet?  Seems
  1423.       like we need one...
  1424.  
  1425.  
  1426.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  1427.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  1428.  _/ _/_/  _/  _/       _/ _/
  1429. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  1430.  
  1431.  
  1432. ---------------------------
  1433.  
  1434. >From rmah@panix.com (Robert S. Mah)
  1435. Subject: Thread Mgr for blocking I-O
  1436. Date: Sat, 21 May 1994 03:14:19 -0500
  1437. Organization: One Step Beyond
  1438.  
  1439. I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1440. as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1441. was wondering if anyone else has tried this.
  1442.  
  1443. For example, while the article recomends putting the I/O thread to sleep,
  1444. and using a wake up thread which is triggered by the completion routine,
  1445. I was wondering how much less efficient a simpler solutio would be.
  1446.  
  1447. That is, instead of...
  1448.  
  1449.    I/O Thread
  1450.       Create WakeUp thread in stopped state
  1451.       Async call with completion routine
  1452.       Sleep this thread
  1453.       Handle results
  1454.  
  1455.    WakeUp Thread
  1456.       Wakeup the I/O thread
  1457.  
  1458.    Completion Routine
  1459.       Wakeup the WakeUp thread
  1460.  
  1461. How about...
  1462.  
  1463.    I/O Thread
  1464.       Async call without completion routine
  1465.       while ioResult not done
  1466.          Yield
  1467.       Handle results
  1468.  
  1469. So, while the I/O thread is always running, and does not sleep, thereby
  1470. hogging resources, does this incur _that_ much overhead?  I have a 
  1471. suspician that this would be more efficient than calling WaitNextEvent
  1472. (i.e. in a single threaded app) instead of Yield.  Or would it?
  1473.  
  1474. Cheers,
  1475. Rob
  1476. ___________________________________________________________________________
  1477. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1478.  
  1479. +++++++++++++++++++++++++++
  1480.  
  1481. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1482. Date: 22 May 1994 02:06:41 GMT
  1483. Organization: Microplex Pty Ltd
  1484.  
  1485. Robert S. Mah (rmah@panix.com) wrote:
  1486. : I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1487. : as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1488. : was wondering if anyone else has tried this.
  1489.  
  1490. : For example, while the article recomends putting the I/O thread to sleep,
  1491. : and using a wake up thread which is triggered by the completion routine,
  1492. : I was wondering how much less efficient a simpler solutio would be.
  1493.  
  1494. : That is, instead of...
  1495.  
  1496. :    I/O Thread
  1497. :       Create WakeUp thread in stopped state
  1498. :       Async call with completion routine
  1499. :       Sleep this thread
  1500. :       Handle results
  1501.  
  1502. :    WakeUp Thread
  1503. :       Wakeup the I/O thread
  1504.  
  1505. :    Completion Routine
  1506. :       Wakeup the WakeUp thread
  1507.  
  1508. : How about...
  1509.  
  1510. :    I/O Thread
  1511. :       Async call without completion routine
  1512. :       while ioResult not done
  1513. :          Yield
  1514. :       Handle results
  1515.  
  1516. : So, while the I/O thread is always running, and does not sleep, thereby
  1517. : hogging resources, does this incur _that_ much overhead?  I have a 
  1518. : suspician that this would be more efficient than calling WaitNextEvent
  1519. : (i.e. in a single threaded app) instead of Yield.  Or would it?
  1520.  
  1521. I have been using the second method you described above for some time 
  1522. now, both with the original threads package and the new stuff. Sure, you 
  1523. get a lot of thread swapping, but this is pretty cheap these days.
  1524.  
  1525. The technique described in Develop seems like a lot of trouble to me. I 
  1526. would love to see someone justify it. (That is, I want to know the 
  1527. technical reasons why it should be done that way.)
  1528.  
  1529. : Cheers,
  1530. : Rob
  1531. : ___________________________________________________________________________
  1532. : Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1533.  
  1534. Steve Coy
  1535. Resolve Software (WA) Pty Ltd
  1536.  
  1537.  
  1538. +++++++++++++++++++++++++++
  1539.  
  1540. >From qmot@cs.mcgill.ca (Thomas PUSHPATHADAM)
  1541. Date: 22 May 1994 08:33:37 GMT
  1542. Organization: SOCS, McGill University, Montreal, Canada
  1543.  
  1544. Path: NewsWatcher!user
  1545. Date: Sun, 22 May 1994 04:16:58 -0400
  1546. From: paul@architecture.mcgill.ca (Paul Lalonde)
  1547. Newsgroups: comp.sys.mac.programmer
  1548. Followup-To: comp.sys.mac.programmer
  1549. Subject: Re: Thread Mgr for blocking I/O
  1550. Message-ID: <paul-220594041658@132.206.27.50>
  1551. References: <rmah-210594031419@rmah.dialup.access.net>
  1552. Organization: McGill University School of Architecture
  1553.  
  1554. In article <rmah-210594031419@rmah.dialup.access.net>, rmah@panix.com (Robert S. Mah) wrote:
  1555.  
  1556. > I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1557. > as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1558. > was wondering if anyone else has tried this.
  1559.  
  1560. [stuff deleted]
  1561.  
  1562. > So, while the I/O thread is always running, and does not sleep, thereby
  1563. > hogging resources, does this incur _that_ much overhead?  I have a 
  1564. > suspician that this would be more efficient than calling WaitNextEvent
  1565. > (i.e. in a single threaded app) instead of Yield.  Or would it?
  1566.  
  1567. Well, if you have several threads that are looping like the example above 
  1568. (the technical term is "busy-waiting"), you may spend a lot of time just 
  1569. switching contexts for no reason.  The technique illustrated in develop 17, 
  1570. although quite a bit more complicated, has the advantage of not having any 
  1571. busy-waiting threads.
  1572.  
  1573. If you have CodeWarrior, DR/3 includes some PowerPlant classes for 
  1574. implementing threads.  They let you do thread-blocking I/O relatively 
  1575. painlessly.  You also get some semaphore classes and a class for inter-
  1576. thread communication.
  1577.  
  1578. Paul Lalonde
  1579. paul@architecture.mcgill.ca
  1580.  
  1581. +++++++++++++++++++++++++++
  1582.  
  1583. >From rmah@panix.com (Robert S. Mah)
  1584. Date: Sun, 22 May 1994 22:42:45 -0500
  1585. Organization: One Step Beyond
  1586.  
  1587. qmot@cs.mcgill.ca (Thomas PUSHPATHADAM) wrote:
  1588.  
  1589. > rmah@panix.com (Robert S. Mah) wrote:
  1590. > > I'm currently experimenting with the Thread Mgr to implement blocking I/O
  1591. > > as per the examples in develop 17.  I'm doing this with MacTCP 2.0.x and
  1592. > > was wondering if anyone else has tried this.
  1593. > [stuff deleted]
  1594. > > So, while the I/O thread is always running, and does not sleep, thereby
  1595. > > hogging resources, does this incur _that_ much overhead?  I have a 
  1596. > > suspician that this would be more efficient than calling WaitNextEvent
  1597. > > (i.e. in a single threaded app) instead of Yield.  Or would it?
  1598. > Well, if you have several threads that are looping like the example above 
  1599. > (the technical term is "busy-waiting"), you may spend a lot of time just 
  1600. > switching contexts for no reason.  The technique illustrated in develop 17, 
  1601. > although quite a bit more complicated, has the advantage of not having any 
  1602. > busy-waiting threads.
  1603. > If you have CodeWarrior, DR/3 includes some PowerPlant classes for 
  1604. > implementing threads.  They let you do thread-blocking I/O relatively 
  1605. > painlessly.  You also get some semaphore classes and a class for inter-
  1606. > thread communication.
  1607.  
  1608. Ohhh, I can't wait for DR/3 to get to my hot little hands!
  1609.  
  1610. But...back to the theory.  What I've done currently is the following...
  1611.  
  1612. I/O Thread
  1613.   Async Call with FrontProcess completion
  1614.   while not finished
  1615.     YieldToAnyTask
  1616.   Do my stuff
  1617.  
  1618. FrontProcess completion
  1619.   SetFrontProcess to my process
  1620.  
  1621. This gives me very good throughput, but seems to be, like you said, hogging
  1622. lot's of CPU time -- well more than chained async I/O calls anyway.  .
  1623.  
  1624. Are there any other techniques?  Why can't one just do the following...
  1625.  
  1626. I/O Thread
  1627.   Async Call with no completion
  1628.   if doneFlag is true
  1629.      Sleep this thread
  1630.   Do my stuff
  1631.  
  1632. Wakeup completion
  1633.   Wakeup completion thread
  1634.   set doneFlag to true
  1635.  
  1636. Can one get a deadlock situation with this?  I don't see how.  Or is it 
  1637. really bad to wakeup a thread that isn't asleep?
  1638.  
  1639. Cheers,
  1640. Rob
  1641. ___________________________________________________________________________
  1642. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1643.  
  1644. +++++++++++++++++++++++++++
  1645.  
  1646. >From Manuel Veloso <veloso@netcom.com>
  1647. Date: Mon, 23 May 1994 03:01:44 GMT
  1648. Organization: Ibex Productions
  1649.  
  1650. In article <2rmenh$8bt@inferno.mpx.com.au> Stephen F Coy, stevec@jolt.mpx.com.au writes:
  1651. >I have been using the second method you described above for some time 
  1652. >now, both with the original threads package and the new stuff. Sure, you 
  1653. >get a lot of thread swapping, but this is pretty cheap these days.
  1654. >
  1655. >The technique described in Develop seems like a lot of trouble to me. I 
  1656. >would love to see someone justify it. (That is, I want to know the 
  1657. >technical reasons why it should be done that way.)
  1658.  
  1659. Maybe it's one of those examples that's a bit too complicated, but illustrated
  1660. the point of sleep/wake. If the routine in question required that there
  1661. be some kind of completion routine (like ADSP or MacTCP) for handling
  1662. callbacks/parameters, the yield() method wouldn't work. Maybe also
  1663. if you were doing a socket listener, etc.
  1664.  
  1665. Still, for async IO that doesn't require a completion routine, way #2
  1666. is a whole lot easier.
  1667.  
  1668. +++++++++++++++++++++++++++
  1669.  
  1670. >From rmah@panix.com (Robert S. Mah)
  1671. Date: Mon, 23 May 1994 07:04:10 -0500
  1672. Organization: One Step Beyond
  1673.  
  1674. Manuel Veloso <veloso@netcom.com> wrote:
  1675.  
  1676. > Maybe it's one of those examples that's a bit too complicated, but illustrated
  1677. > the point of sleep/wake. If the routine in question required that there
  1678. > be some kind of completion routine (like ADSP or MacTCP) for handling
  1679. > callbacks/parameters, the yield() method wouldn't work. Maybe also
  1680. > if you were doing a socket listener, etc.
  1681. > Still, for async IO that doesn't require a completion routine, way #2
  1682. > is a whole lot easier.
  1683.  
  1684. Oh, the develop example isn't so much because of a completion routine
  1685. requirement as much as a problem with trying to sleep a thread after the
  1686. async routine completes.
  1687.  
  1688. The basic idea behind the develop article is to...
  1689.  
  1690. 1. Start the async routine
  1691. 2. Sleep this thread
  1692. ...
  1693. 3. Wake the thread from the completion routine.
  1694.  
  1695. Note, that, as Anderson & Post put it, "there is a window of misfortune 
  1696. after the thread makes the asynchronous call and before it completes the
  1697. sleep call"  I.e. you're completion can fire off between #1 and #2.  So 
  1698. you wake, then you sleep and never awake.
  1699.  
  1700. Cheers,
  1701. Rob
  1702. ___________________________________________________________________________
  1703. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1704.  
  1705. +++++++++++++++++++++++++++
  1706.  
  1707. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1708. Date: 23 May 1994 13:54:54 GMT
  1709. Organization: Microplex Pty Ltd
  1710.  
  1711. Manuel Veloso (veloso@netcom.com) wrote:
  1712. : In article <2rmenh$8bt@inferno.mpx.com.au> Stephen F Coy, stevec@jolt.mpx.com.au writes:
  1713. : >I have been using the second method you described above for some time 
  1714. : >now, both with the original threads package and the new stuff. Sure, you 
  1715. : >get a lot of thread swapping, but this is pretty cheap these days.
  1716. : >
  1717. : >The technique described in Develop seems like a lot of trouble to me. I 
  1718. : >would love to see someone justify it. (That is, I want to know the 
  1719. : >technical reasons why it should be done that way.)
  1720.  
  1721. : Maybe it's one of those examples that's a bit too complicated, but illustrated
  1722. : the point of sleep/wake. If the routine in question required that there
  1723. : be some kind of completion routine (like ADSP or MacTCP) for handling
  1724. : callbacks/parameters, the yield() method wouldn't work. Maybe also
  1725. : if you were doing a socket listener, etc.
  1726.  
  1727. But these are the exact places that I have been using the yield technique!
  1728. I can't think of ANY part of the Mac OS that REQUIRES a completion 
  1729. routine to perform async I/O. (I am of course willing to be corrected 
  1730. here :) ).
  1731.  
  1732. Typically, the yield loop polls the ioresult field of the parameter block 
  1733. until it is not 1.
  1734.  
  1735.  
  1736. : Still, for async IO that doesn't require a completion routine, way #2
  1737. : is a whole lot easier.
  1738.  
  1739. - ----
  1740. Steve Coy
  1741.  
  1742.  
  1743. +++++++++++++++++++++++++++
  1744.  
  1745. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1746. Date: Wed, 25 May 1994 19:20:09 GMT
  1747. Organization: Apple Computer
  1748.  
  1749. In article <rmah-210594031419@rmah.dialup.access.net> Robert S. Mah,
  1750. rmah@panix.com writes:
  1751. > So, while the I/O thread is always running, and does not sleep, thereby
  1752. > hogging resources, does this incur _that_ much overhead?
  1753.  
  1754. Isn't 50% of your CPU time spent in pre-emptive threads, if any are ready to
  1755. run? This implies that the Thread Manager will make sure your app spends
  1756. exactly 50% of its time in that little wait loop. (Disclaimer: I have not
  1757. used the Thread Manager, but I've read the documentation closely...)
  1758.  
  1759. --Jens Alfke
  1760.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1761.             .apple.com              Rebel girl you are the queen of my world
  1762.  
  1763. +++++++++++++++++++++++++++
  1764.  
  1765. >From rmah@panix.com (Robert S. Mah)
  1766. Date: Wed, 25 May 1994 20:13:31 -0500
  1767. Organization: One Step Beyond
  1768.  
  1769. Jens Alfke <jens_alfke@powertalk.apple.com> wrote:
  1770.  
  1771. > Robert S. Mah, rmah@panix.com writes:
  1772. > > So, while the I/O thread is always running, and does not sleep, 
  1773. > > thereby hogging resources, does this incur _that_ much overhead?
  1774. > Isn't 50% of your CPU time spent in pre-emptive threads, if any are 
  1775. > ready to run? This implies that the Thread Manager will make sure your  
  1776. > app spends exactly 50% of its time in that little wait loop. 
  1777. > (Disclaimer: I have not used the Thread Manager, but I've read the
  1778. > documentation closely...)
  1779.  
  1780. I'm not using pre-emptive threads since they don't work on the PowerMac's.
  1781. And you're _almost_ right.  Pre-emptive threads get 50% of you're
  1782. application's timeslice, not 50% of the CPU since the "pre-emptive" threads
  1783. only pre-empt when your app is awake.  Or did you mean that and I'm read-
  1784. ing you wrong...hmm...
  1785.  
  1786. Anyway, my main thing now is a search for good a profiling tool that 
  1787. measures the load on the system by each process.  This will help my quest
  1788. for multi-threaded efficiency immeasurably.
  1789.  
  1790. Cheers,
  1791. Rob
  1792. ___________________________________________________________________________
  1793. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1794.  
  1795. +++++++++++++++++++++++++++
  1796.  
  1797. >From jlscott@tigr.org (John L. Scott)
  1798. Date: Tue, 31 May 1994 14:41:07 GMT
  1799. Organization: Self
  1800.  
  1801. In article <rmah-220594224245@rmah.dialup.access.net>, rmah@panix.com
  1802. (Robert S. Mah) wrote:
  1803.  
  1804. > qmot@cs.mcgill.ca (Thomas PUSHPATHADAM) wrote:
  1805. > Are there any other techniques?  Why can't one just do the following...
  1806. > I/O Thread
  1807. >   Async Call with no completion
  1808. >   if doneFlag is true
  1809. >      Sleep this thread
  1810. >   Do my stuff
  1811. > Wakeup completion
  1812. >   Wakeup completion thread
  1813. >   set doneFlag to true
  1814. > Can one get a deadlock situation with this?  I don't see how.  Or is it 
  1815. > really bad to wakeup a thread that isn't asleep?
  1816.  
  1817.  
  1818. Welcome to the headachy world of concurrent programming.  If it can
  1819. preempt, it will preempt.
  1820.  
  1821.  Async Call WITH completion
  1822.  if doneFlag is FALSE
  1823.                                   <---- Completion routine happens here
  1824.    Sleep this thread
  1825.  Do my stuff
  1826.  
  1827. If your code is interrupted AFTER the conditional but BEFORE the sleep
  1828. call, you will sleep forever.  That is a very small window of opportunity,
  1829. but it will eventually happen.  As far as I know, there are no other
  1830. solutions other than busy-waiting or using a second thread as in Develop
  1831. 17.
  1832.  
  1833. --John L. Scott
  1834.  
  1835. +++++++++++++++++++++++++++
  1836.  
  1837. >From eastman@bnr.ca (Gordon Eastman)
  1838. Date: Tue, 31 May 1994 21:36:53 GMT
  1839. Organization: Bell-Northern Research
  1840.  
  1841. In article <jlscott-310594094108@jlscott.tigr.org>, jlscott@tigr.org (John
  1842. L. Scott) wrote:
  1843.  
  1844. > Welcome to the headachy world of concurrent programming.  If it can
  1845. > preempt, it will preempt.
  1846. >  Async Call WITH completion
  1847. >  if doneFlag is FALSE
  1848. >                                   <---- Completion routine happens here
  1849. >    Sleep this thread
  1850. >  Do my stuff
  1851. > If your code is interrupted AFTER the conditional but BEFORE the sleep
  1852. > call, you will sleep forever.  That is a very small window of opportunity,
  1853. > but it will eventually happen.  As far as I know, there are no other
  1854. > solutions other than busy-waiting or using a second thread as in Develop
  1855. > 17.
  1856. > --John L. Scott
  1857.  
  1858. Here is another solution. 
  1859.  
  1860. >From the completion routine, check the state of the thread. If it is
  1861. sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1862. install a time manager task that triggers in a bit and try again.
  1863.  
  1864. I have done this successfully, and see with my Code Warrior DR/3 CD that
  1865. arrived today that the PowerPlant thread class library also uses this
  1866. technique.
  1867.  
  1868. -- Gord
  1869.  
  1870. +++++++++++++++++++++++++++
  1871.  
  1872. >From rmah@panix.com (Robert S. Mah)
  1873. Date: Wed, 01 Jun 1994 10:25:27 -0500
  1874. Organization: One Step Beyond
  1875.  
  1876. eastman@bnr.ca (Gordon Eastman) wrote:
  1877.  
  1878. > From the completion routine, check the state of the thread. If it is
  1879. > sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1880. > install a time manager task that triggers in a bit and try again.
  1881. > I have done this successfully, and see with my Code Warrior DR/3 CD that
  1882. > arrived today that the PowerPlant thread class library also uses this
  1883. > technique.
  1884.  
  1885. Better be careful there.  If I understand you correctly, you're saying
  1886. do this...
  1887.  
  1888. I/O Thread
  1889.   Async call with completion
  1890.   Sleep this thread
  1891.  
  1892. Completion
  1893.   if I/O Thread is asleap
  1894.     Wake I/O Thread
  1895.  
  1896. Potentially, the completion routine could fire before you sleep the I/O
  1897. thread.  This means that the I/O thread will sleep forever!  Not much 
  1898. chance, but it could happen.  This was precisely the problem that the
  1899. example in develop 17 (the one that uses a wake up thread) was supposed
  1900. to solve.
  1901.  
  1902. Cheers,
  1903. Rob
  1904. ___________________________________________________________________________
  1905. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1906.  
  1907. +++++++++++++++++++++++++++
  1908.  
  1909. >From qmot@cs.mcgill.ca (Thomas PUSHPATHADAM)
  1910. Date: 1 Jun 1994 16:50:26 GMT
  1911. Organization: SOCS, McGill University, Montreal, Canada
  1912.  
  1913. (*** Posting from borrowed account ***)
  1914.  
  1915. rmah@panix.com (Robert S. Mah) wrote:
  1916.  
  1917. > eastman@bnr.ca (Gordon Eastman) wrote:
  1918.  
  1919. > > From the completion routine, check the state of the thread. If it is
  1920. > > sleeping, wake it. Otherwise you hit that small window of misfortune,
  1921. > > so
  1922. > > install a time manager task that triggers in a bit and try again.
  1923. > >
  1924. > > I have done this successfully, and see with my Code Warrior DR/3 CD
  1925. > > that
  1926. > > arrived today that the PowerPlant thread class library also uses this
  1927. > > technique.
  1928.   
  1929. > Better be careful there.  If I understand you correctly, you're saying
  1930. > do this...
  1931.    
  1932. >  I/O Thread
  1933. >    Async call with completion
  1934. >    Sleep this thread
  1935. >
  1936. >  Completion
  1937. >    if I/O Thread is asleap
  1938. >      Wake I/O Thread
  1939. > Potentially, the completion routine could fire before you sleep the I/O
  1940. > thread.  This means that the I/O thread will sleep forever!  Not much
  1941. > chance, but it could happen.  This was precisely the problem that the
  1942. > example in develop 17 (the one that uses a wake up thread) was supposed
  1943. > to solve.
  1944.  
  1945. Actually, I think he meant to do this:
  1946.  
  1947. I/O thread
  1948.   async call with completion
  1949.   sleep thread
  1950.  
  1951. Completion routine
  1952.   if I/O thread is asleep
  1953.     wake I/O thread
  1954.   else
  1955.     install time manager task with same completion routine
  1956.  
  1957. In this way, if the completion routine executes before the I/O thread
  1958. has been put to sleep, the completion routine just arranged to regain 
  1959. control after a small delay.  This is precisely the method used in the 
  1960. threads classes in PowerPlant.
  1961.  
  1962. Strictly speaking, this is a form of busy waiting.  However, the time 
  1963. window within which the busy waiting occurs is very small, assuming 
  1964. you don't something like call WaitNextEvent between the async call 
  1965. and the sleep call.
  1966.  
  1967. Cheers,
  1968. Paul Lalonde
  1969. paul@architecure.mcgill.ca
  1970.  
  1971.  
  1972. +++++++++++++++++++++++++++
  1973.  
  1974. >From eastman@bnr.ca (Gord Eastman)
  1975. Date: Wed, 1 Jun 1994 16:23:21 GMT
  1976. Organization: Bell-Northern Research
  1977.  
  1978. In article <rmah-010694102527@rmah.dialup.access.net>, rmah@panix.com
  1979. (Robert S. Mah) wrote:
  1980.  
  1981. > eastman@bnr.ca (Gordon Eastman) wrote:
  1982. > > From the completion routine, check the state of the thread. If it is
  1983. > > sleeping, wake it. Otherwise you hit that small window of misfortune, so
  1984. > > install a time manager task that triggers in a bit and try again.
  1985. > > 
  1986. > > I have done this successfully, and see with my Code Warrior DR/3 CD that
  1987. > > arrived today that the PowerPlant thread class library also uses this
  1988. > > technique.
  1989. > Better be careful there.  If I understand you correctly, you're saying
  1990. > do this...
  1991. > I/O Thread
  1992. >   Async call with completion
  1993. >   Sleep this thread
  1994. > Completion
  1995. >   if I/O Thread is asleap
  1996. >     Wake I/O Thread
  1997. > Potentially, the completion routine could fire before you sleep the I/O
  1998. > thread.  This means that the I/O thread will sleep forever!  Not much 
  1999. > chance, but it could happen.  This was precisely the problem that the
  2000. > example in develop 17 (the one that uses a wake up thread) was supposed
  2001. > to solve.
  2002.  
  2003. And the precise problem that the time manager task solves. You seem to have
  2004. missed the "Otherwise" sentence of my post.The completion routine would be:
  2005.  
  2006. if I/O Thread is asleep
  2007.   Wake I/O Thread
  2008. else
  2009.   Install Time Manager task
  2010.  
  2011. When the Time Manager task fires,
  2012. if I/O Thread is asleep
  2013.   Wake I/O Thread
  2014. else
  2015.   reinstall Time Manager task
  2016.  
  2017. -- Gord
  2018.  
  2019.     
  2020.  
  2021. +++++++++++++++++++++++++++
  2022.  
  2023. >From rmah@panix.com (Robert S. Mah)
  2024. Date: Wed, 01 Jun 1994 19:47:34 -0500
  2025. Organization: One Step Beyond
  2026.  
  2027. eastman@bnr.ca (Gord Eastman) wrote:
  2028.  
  2029. > And the precise problem that the time manager task solves. You seem to have
  2030. > missed the "Otherwise" sentence of my post.The completion routine would be:
  2031.  
  2032. Oops...sorry about that.  I'll endevour to be more attentive next time :-)
  2033.  
  2034. Cheers,
  2035. Rob
  2036. ___________________________________________________________________________
  2037. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  2038.  
  2039. ---------------------------
  2040.  
  2041. End of C.S.M.P. Digest
  2042. **********************
  2043.  
  2044.  
  2045. ˇ